<template>
	<view class="setup">
		<statusBar />
		<view class="contract">
			<!-- 设置 -->
			<view class="nav f">
				<image src="../../static/setup/jiantou.png" mode=""></image>
				<view>设置</view>
			</view>
			<!-- 门店 -->
			<view class="f_two">
				<!-- <view>云贝餐饮</view> -->
				<view v-if="this.money==''" @tap="Login">登录</view>
				<view v-else @tap="Login">{{ shopName }}</view>
				<view>切换门店</view>
			</view>
			<!-- 我的钱包 -->
			<view class="wallt">
				<view class="wallet">
					<view>我的钱包</view>
					<view @tap="wallt">
						<view>查看钱包余额</view>
						<image src="../../static/setup/jiantou1.png" mode=""></image>
					</view>
				</view>
				<!-- 账户余额 -->
				<view class="banner">
					<view class="banner_one">
						<view>账户余额</view>
						<view>商品数</view>
						<view>
							<view>消息提醒</view>
							<view>NEW</view>
						</view>
					</view>
					<view class="banner_two">
						<view>
							{{ money==""?'0':money }}
							<text>万</text>
						</view>
						<view>
							{{ goodNum==""?'0':goodNum }}
							<text>件</text>
						</view>
						<view>
							0
							<text>条</text>
						</view>
					</view>
				</view>
			</view>

			<!-- 门店设置 -->
			<view class="Settings" @tap="Settings">
				<view>
					<image src="../../static/setup/3.png" mode=""></image>
					<text>门店设置</text>
				</view>
				<view><image src="../../static/setup/jiantou2.png" mode=""></image></view>
			</view>
			<!-- 订单设置 -->
			<view class="Settings" @tap="order">
				<view>
					<image src="../../static/setup/4.png" mode=""></image>
					<text>订单设置</text>
				</view>
				<view><image src="../../static/setup/jiantou2.png" mode=""></image></view>
			</view>
			<!-- 消息和铃声设置 -->
			<view class="Settings" @tap="bell">
				<view>
					<image src="../../static/setup/1.png" mode=""></image>
					<text>消息和铃声设置</text>
				</view>
				<view><image src="../../static/setup/jiantou2.png" mode=""></image></view>
			</view>
			<!-- 打印设置 -->
			<view class="Settings">
				<view>
					<image src="../../static/setup/5.png" mode=""></image>
					<text>打印设置</text>
				</view>
				<view><image src="../../static/setup/jiantou2.png" mode=""></image></view>
			</view>
			<!-- 联系业务经理 -->
			<view class="Settings">
				<view>
					<image src="../../static/setup/6.png" mode=""></image>
					<text>联系业务经理</text>
				</view>
				<view><image src="../../static/setup/jiantou2.png" mode=""></image></view>
			</view>
			<!-- 当前账号 -->
			<view class="Settings">
				<view>
					<image src="../../static/setup/2.png" mode=""></image>
					<text>当前账号</text>
				</view>
				<view>
					<text>{{ this.userinfo.userName == '' ? '--' : this.userinfo.userName }}</text>
					<image src="../../static/setup/jiantou2.png" mode=""></image>
				</view>
			</view>

			<!-- 当前版本 v6.6.0 -->
			<view class="version">当前版本 v6.6.0</view>
			<!-- 退出登录 -->
			<view class="Login" @tap="bindLogin">退出登录</view>
		</view>
	</view>
</template>
<script>
import { mapActions, mapState, mapMutations } from 'vuex';
import { toast } from '@/utils/toast';
import request from '@/utils/request';
import statusBar from '../../components/statusBar/statusBar.vue';
export default {
	data() {
		return {
			money: '',
			shopName: '',
			goodNum: ''
		};
	},
	components: {
		statusBar
	},
	onShow() {
		this.information();
	},

	computed: {
		...mapState('user', ['isLogin', 'uerInfo']),
		...mapState('user', ['userinfo']),
		
	},
	mounted() {
		console.log(this.userinfo, 77);
	},
	methods: {
		...mapMutations('user', ['logout']),
		wallt() {
			uni.navigateTo({
				url: '/pages/Setup/wallt'
			});
		},
		Settings() {
			uni.navigateTo({
				url: '/pages/Setup/Settings'
			});
		},
		order() {
			uni.navigateTo({
				url: '/pages/Setup/order'
			});
		},
		// 手机铃声
		bell() {
			uni.navigateTo({
				url: '/pages/Setup/bell'
			});
		},
		// 登录
		Login() {
			uni.navigateTo({
				url: '/pages/Setup/login'
			});
		},
		// 退出登录
		bindLogin() {
			console.log(111);
			if (this.isLogin) {
				this.logout();
				uni.navigateTo({
					url: '/pages/Setup/login'
				});
			}
		},
		// 商户信息
		information() {
			uni.showLoading({
				duration: 2000
			});
			request('/merchant/index/get-merchant-row', 'post', {}).then(res => {
				console.log(res.data.data, 777);
				if (res.data.code == 1) {
					setTimeout(() => {
						uni.hideLoading();
					}, 500);
					this.shopName = res.data.data.shopName;
					this.money = res.data.data.moeny.money;
					this.goodNum = res.data.data.goodNum;
				}
				try {
					this.shopName = JSON.parse(res.data).data.shopName;
					this.money = JSON.parse(res.data).data.moeny.money;
					this.goodNum = JSON.parse(res.data).data.goodNum;
				} catch (e) {
					this.shopName = res.data.data.shopName;
					this.money = res.data.data.moeny.money;
					this.goodNum = res.data.data.goodNum;
				}
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.setup {
	background: #ffffff !important;
	padding-bottom: 47upx;
	.contract {
		padding: 0 24upx;
		.nav {
			padding-top: 40upx;
			image {
				width: 27upx;
				height: 30upx;
			}
			& > view {
				font-size: 34upx;
				font-family: Source Han Sans CN;
				font-weight: bold;
				color: $bg2-color;
				margin-left: 30upx;
			}
		}

		& > view:nth-child(2) {
			margin-top: 50upx;
			& > view:nth-child(1) {
				font-size: 46upx;
				font-family: Source Han Sans CN;
				font-weight: bold;
				color: $bg2-color;
			}
			& > view:nth-child(2) {
				width: 184upx;
				height: 66upx;
				background: $bg-background;
				border-radius: 33upx;
				font-size: 24upx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: $bg1-color;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}
		& > view:nth-child(3) {
			background: linear-gradient(-16deg, rgba(235, 223, 201, 1) 0%, rgba(246, 238, 227, 1) 100%);
			border-radius: 20upx;
			margin-top: 20upx;
			padding: 36upx 23upx 40upx 40upx;
		}
		// 我的钱包
		.wallt {
			.wallet {
				display: flex;
				align-items: center;
				justify-content: space-between;
				& > view:nth-child(1) {
					font-size: 34upx;
					font-family: Source Han Sans CN;
					font-weight: bold;
					color: $bg2-color;
				}
				& > view:nth-child(2) {
					display: flex;
					align-items: center;
					& > view:nth-child(1) {
						font-size: 26upx;
						font-family: Source Han Sans CN;
						font-weight: 500;
						color: $bg8-color;
					}
					image {
						width: 25upx;
						height: 27upx;
						margin-left: 4upx;
						display: flex;
					}
				}
			}
			.banner {
				padding: 0upx 26upx 0upx 40upx;
				margin-top: 25upx;
				.banner_one {
					display: flex;
					align-items: center;
					justify-content: space-between;
					& > view {
						font-size: 26upx;
						font-family: Source Han Sans CN;
						font-weight: 500;
						color: $bg8-color;
					}
					& > view:nth-child(3) {
						display: flex;
						align-items: center;
						& > view:nth-child(2) {
							background: url(../../static/setup/img.png) no-repeat;
							width: 51upx;
							height: 24upx;
							background: $bg9-color;
							border-radius: 30upx;
							font-size: 18upx;
							font-family: Source Han Sans CN;
							font-weight: 500;
							color: $bg1-color;
							display: flex;
							align-items: center;
							justify-content: center;
							margin-left: 11upx;
							padding: 6upx;
						}
					}
				}
				.banner_two {
					display: flex;
					align-items: center;
					justify-content: space-between;
					// text-align: left;
					margin-top: 30upx;

					& > view {
						font-size: 42upx;
						font-family: Source Han Sans CN;
						font-weight: bold;
						color: $bg8-color;
						width: 27%;

						margin: 0 auto;

						& > text {
							font-size: 24upx;
							font-family: Source Han Sans CN;
							font-weight: 400;
							color: $bg8-color;
							margin-left: 6upx;
						}
					}
				}
			}
		}

		.Settings {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 56upx;
			& > view:nth-child(1) {
				display: flex;
				align-items: center;
				image {
					width: 44upx;
					height: 44upx;
				}
				& > text {
					font-size: 32upx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: $bg2-color;
					margin-left: 26upx;
				}
			}
			& > view:nth-child(2) {
				display: flex;
				align-items: center;
				image {
					width: 34upx;
					height: 33upx;
				}
				& > text {
					font-size: 24upx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: $bg6-color;
				}
			}
		}
		.version {
			font-size: 24upx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: $bg5-color;
			text-align: center;
			margin-top: 84upx;
		}
		.Login {
			width: 100%;
			height: 112upx;
			background: rgba(53, 57, 76, 1);
			border-radius: 56upx;
			font-size: 34upx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: $bg1-color;
			margin-top: 73upx;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
}
</style>
